package com.mhc.haval.manager.impl;

import com.mhc.haval.dal.mapper.ext.RoleExtMapper;
import com.mhc.haval.dal.model.RoleDO;
import com.mhc.haval.dal.query.RoleQuery;
import com.mhc.haval.manager.RoleManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Manager for Role.
 */

@Service
public class RoleManagerImpl implements RoleManager{

    
    @Autowired
    protected RoleExtMapper roleExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(RoleQuery query){
        return roleExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(RoleQuery query){
        return roleExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(RoleDO record){
        return roleExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(RoleDO record){
        return roleExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<RoleDO> selectByQuery(RoleQuery query){
        return roleExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<RoleDO> selectByQueryWithPage(RoleQuery query) {
        PageResult<RoleDO> result = new PageResult<RoleDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public RoleDO selectByPrimaryKey(Long id){
        return roleExtMapper.selectByPrimaryKey(id);
    }

    /**
     * select by staff id.
     */
    @Override
    public List<RoleDO> selectByStaffId(Long staffId){
        return roleExtMapper.selectByStaffId(staffId);
    }

    /**
     * select by dept id.
     */
    @Override
    public List<RoleDO> selectByDeptId(Long deptId){
        return roleExtMapper.selectByDeptId(deptId);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( RoleDO record,  RoleQuery query){
        return roleExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( RoleDO record,  RoleQuery query){

        return roleExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(RoleDO record){
        return roleExtMapper.updateByPrimaryKeySelective(record);
    }
}